package com.googlecode.ddlutilstool.kernel;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.Properties;

/**
 * <p>Class DriverShim</p>
 * 
 * <p>This class overcomes the java ClassLoader problem
 * where JDBC expects the JDBC drivers to be in the java
 * classpath.  Since DDLUtilsTool allows a dynamic classpath
 * using the "lib" subfolder for JDBC drivers, we need to
 * overcome this problem.  This wrapper will contain the
 * driver loaded dynamically, and since this class is loaded
 * in the java classpath, it will be available to JDBC.</p>
 * 
 * <p>This code came coutesy of Nick Sayer:
 * http://www.kfu.com/~nsayer/Java/dyn-jdbc.html.</p>
 */
class DriverShim implements Driver {
	private Driver driver;
	DriverShim(Driver d) {
		this.driver = d;
	}
	public boolean acceptsURL(String u) throws SQLException {
		return this.driver.acceptsURL(u);
	}
	public Connection connect(String u, Properties p) throws SQLException {
		return this.driver.connect(u, p);
	}
	public int getMajorVersion() {
		return this.driver.getMajorVersion();
	}
	public int getMinorVersion() {
		return this.driver.getMinorVersion();
	}
	public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
		return this.driver.getPropertyInfo(u, p);
	}
	public boolean jdbcCompliant() {
		return this.driver.jdbcCompliant();
	}
}